//
//  BNConnectController.m
//  BeautifulNote
//
//  Created by Apple on 2019/7/24.
//  Copyright © 2019 Maker. All rights reserved.
//

#import "BNConnectController.h"

@interface BNConnectController ()

@property (nonatomic, strong) UIButton *backButton;
@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *contentLb;

@property (nonatomic, strong) UIButton *phoneButton;
@property (nonatomic, strong) UIButton *emailButton;

@end

@implementation BNConnectController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self initViews];
}

- (void)clickEmail {
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    [pasteboard setString:@"153751320@qq.com"];
    [SVProgressHUD showSuccessWithStatus:@"邮箱地址已经复制到粘贴板"];
}

- (void)clickTepl {
    NSMutableString* str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"17620873469"];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}

- (void)initViews {
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.backButton];
    [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(SafeAreaTopHeight + StatusBarHeight + 15);
        make.width.height.mas_equalTo(25);
    }];
    
    [self.view addSubview:self.titleLb];
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backButton);
        make.left.mas_equalTo(55);
        make.right.mas_equalTo(-55);
    }];
    
    [self.view addSubview:self.contentLb];
    [self.contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.backButton.mas_bottom).mas_equalTo(20);
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
    }];
    
    [self.view addSubview:self.phoneButton];
    [self.phoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentLb.mas_bottom).mas_equalTo(20);
        make.left.mas_equalTo(20);
        make.width.mas_equalTo(175);
        make.height.mas_equalTo(30);
    }];
    
    [self.view addSubview:self.emailButton];
    [self.emailButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.phoneButton.mas_bottom).mas_equalTo(20);
        make.left.mas_equalTo(20);
        make.width.mas_equalTo(230);
        make.height.mas_equalTo(30);
    }];
}


- (void)clickBackButton {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (UIButton *)backButton {
    if (!_backButton) {
        _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [_backButton addTarget:self action:@selector(clickBackButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backButton;
}

- (UILabel *)titleLb {
    if (!_titleLb) {
        _titleLb = [UILabel new];
        _titleLb.font = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:16];
        _titleLb.textColor = [UIColor blackColor];
        _titleLb.textAlignment = NSTextAlignmentCenter;
        _titleLb.text = @"联系我们";
    }
    return _titleLb;
}

- (UIButton *)emailButton {
    if (!_emailButton) {
        _emailButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_emailButton setTitle:@"邮箱：153751320@qq.com" forState:UIControlStateNormal];
        [_emailButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        _emailButton.titleLabel.font = mediumFont(18);
        [_emailButton addTarget:self action:@selector(clickEmail) forControlEvents:UIControlEventTouchUpInside];
    }
    return _emailButton;
}

- (UILabel *)contentLb {
    if (!_contentLb) {
        _contentLb = [UILabel new];
        _contentLb.font = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:16];
        _contentLb.textColor = [UIColor blackColor];
        _contentLb.text = @"尊敬的用户您好：\n非常感谢您使用这款应用，很荣幸能在此为您服务，您的使用和建议是我们进步的阶梯！如果有需要改进的地方，请联系我们：";
        _contentLb.numberOfLines = 0;
    }
    return _contentLb;
}


- (UIButton *)phoneButton {
    if (!_phoneButton) {
        _phoneButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_phoneButton setTitle:@"电话：17620873469" forState:UIControlStateNormal];
        [_phoneButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        _phoneButton.titleLabel.font = mediumFont(18);
        [_phoneButton addTarget:self action:@selector(clickTepl) forControlEvents:UIControlEventTouchUpInside];
    }
    return _phoneButton;
}

@end
